<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Example: Customize a Chart</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <script src="../../build/yui/yui-min.js"></script>
</head>
<body>

<div id="doc">
    <h1>Example: Customize a Chart</h1>

    

    <div class="yui3-g">
        <div id="main" class="yui3-u">
            <div class="content"><style scoped>
#mychart {
    margin:10px 10px 10px 10px;
    width:90%;
    max-width: 800px;
    height:400px;
}
</style>
<div class="intro">
<p>This example shows how to use a <code>Chart</code>'s <code>styles</code> attribute to customize a <code>Chart</code>.</p>
</div>
<div class="example">
<div id="mychart"></div>
<script type="text/javascript">
(function() {
    YUI().use('charts', function (Y) 
    { 
        var myDataValues = [ 
            {date:"5/1/2010", international:2000, expenses:3700, domestic:2200}, 
            {date:"5/2/2010", international:50, expenses:9100, domestic:100}, 
            {date:"5/3/2010", international:400, expenses:1100, domestic:1500}, 
            {date:"5/4/2010", international:200, expenses:1900, domestic:2800}, 
            {date:"5/5/2010", international:5000, expenses:5000, domestic:2650}
        ];
        var styleDef = {
            axes:{
                values:{
                    label:{
                        rotation:-45,
                        color:"#ff0000"
                    }
                },
                date:{
                    label:{
                        rotation:-45,
                        color: "#ff0000"
                    }
                }
            },
            series:{
                international:{
                    marker:{
                        fill:{
                            color:"#ff8888"
                        },
                        border:{
                            color:"#ff0000"
                        },
                        over:{
                            fill:{
                                color:"#ffffff"
                            },
                            border:{
                                color:"#fe0000"
                            },
                            width: 12,
                            height: 12
                        }
                    },
                    line:{
                        color:"#ff0000"
                    }
                },
                expenses:{
                    line:{
                        color:"#999"
                    },
                    marker:
                    {
                        fill:{
                            color:"#ddd"
                        },
                        border:{
                            color:"#999"
                        },
                        over: {
                            fill: {
                                color: "#eee"
                            },
                            border: {
                                color: "#000"
                            },
                            width: 12,
                            height: 12
                        }
                    }
                },
                domestic: {
                    marker: {
                        over: {
                            fill: {
                                color: "#eee"
                            },
                            width: 12,
                            height: 12
                        }
                    }
                }
            }
        };

        var mychart = new Y.Chart({
                                    dataProvider:myDataValues, 
                                    interactionType:"planar", 
                                    categoryKey:"date", 
                                    styles:styleDef, 
                                    horizontalGridlines:true, 
                                    verticalGridlines:true, 
                                    render:"#mychart"
                                });

    });
})();
</script>

</div>
<h3>Customizing a <code>Chart</code> with the <code>styles</code> attribute.</h3>

<p>Many properties of the chart and its components can be customized through the <code>Chart</code>'s <code>styles</code> attribute. The <code>styles</code> attribute is an object literal containing
references to different components of a chart. These references each containing object literals specifying different properties for each component. The <code>styles</code> attribute breaks up
as follows.</p>

<ul>
    <li>graph: a key based object referencing the customizable properties of the <code>Chart</code> instance's <code>Graph</code>.</li>
    <li>axes: a key based object containing references to the customizable properties of each axis in the <code>Chart</code>. By default, the primary category axis key is "category" and the primary value
    axis key is "values".</li>
    <li>series: a key based object container references to the customizable properties of each series in the <code>Chart</code>.
</ul>

<p>In this example, we'll style the axis labels and the series colors. For both axes, we will change the colors and rotation. For two of the series, we will change their line and marker colors. 
For all of the series, we will change over properties of the markers to create a mouseover effect.</p>

<pre class="code prettyprint">YUI().use(&#x27;charts&#x27;, function (Y) 
{ 
    var styleDef = {
        axes:{
            values:{
                label:{
                    rotation:-45,
                    color:&quot;#ff0000&quot;
                }
            },
            date:{
                label:{
                    rotation:-45,
                    color: &quot;#ff0000&quot;
                }
            }
        },
        series:{
            international:{
                marker:{
                    fill:{
                        color:&quot;#ff8888&quot;
                    },
                    border:{
                        color:&quot;#ff0000&quot;
                    },
                    over:{
                        fill:{
                            color:&quot;#ffffff&quot;
                        },
                        border:{
                            color:&quot;#fe0000&quot;
                        },
                        width: 12,
                        height: 12
                    }
                },
                line:{
                    color:&quot;#ff0000&quot;
                }
            },
            expenses:{
                line:{
                    color:&quot;#999&quot;
                },
                marker:
                {
                    fill:{
                        color:&quot;#ddd&quot;
                    },
                    border:{
                        color:&quot;#999&quot;
                    },
                    over: {
                        fill: {
                            color: &quot;#eee&quot;
                        },
                        border: {
                            color: &quot;#000&quot;
                        },
                        width: 12,
                        height: 12
                    }
                }
            },
            domestic: {
                marker: {
                    over: {
                        fill: {
                            color: &quot;#eee&quot;
                        },
                        width: 12,
                        height: 12
                    }
                }
            }
        }
    };
    var mychart = new Y.Chart({
                                dataProvider:myDataValues, 
                                interactionType:&quot;planar&quot;, 
                                categoryKey:&quot;date&quot;, 
                                styles:styleDef, 
                                horizontalGridlines:true, 
                                verticalGridlines:true, 
                                render:&quot;#mychart&quot;
                            });
});</pre>

</div>
        </div>

        <div id="sidebar" class="yui3-u">
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                                    <li data-description="Shows how to use Charts to create a basic chart.">
                                        <a href="charts-simple.html">Basic Charts Implementation</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with multiple series.">
                                        <a href="charts-multiseries.html">Chart with Multiple Series</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a column chart with multiple series.">
                                        <a href="charts-column.html">Specify Chart Type</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a column chart with a stacked numeric axis.">
                                        <a href="charts-stackedcolumn.html">Create Stacked Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with a time axis.">
                                        <a href="charts-timeaxis.html">Create a Chart with a Time Axis</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to add gridlines to a chart.">
                                        <a href="charts-gridlines.html">Add Gridlines to a Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with planar based events.">
                                        <a href="charts-stackedarea.html">Create a Stacked Area Chart with Planar Based Events</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to use a chart&#x27;s styles attribute to customize a chart.">
                                        <a href="charts-globalstyles.html">Customize a Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to customize the default tooltip of a chart.">
                                        <a href="charts-customizedtooltip.html">Customize a Chart&#x27;s Tooltip</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to explicitly define the axes and series for a chart.">
                                        <a href="charts-objectstyles.html">Define a Chart&#x27;s Axes and Series</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to use charts to create a pie chart.">
                                        <a href="charts-pie.html">Pie Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with multiple value axes.">
                                        <a href="charts-dualaxes.html">Dual Axes Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to access a chart instance&#x27;s value axis after the chart has rendered.">
                                        <a href="charts-axisupdate.html">Update Chart Axis</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to access a chart instance&#x27;s seriesCollection after the chart has rendered.">
                                        <a href="charts-seriesupdate.html">Update Chart Series</a>
                                    </li>
                                
                            
                        </ul>
                    </div>
                </div>
            

            
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

</body>
</html>
